<?php
include "../lib/DAL/TblCTDT.php";
class TblCTDTBLL{
    function __construct(){
        
    }
    
    function __destruct(){
        
    }
    public function getListMonCTDT(){
        $sql ="select * from tbl_CTDT";
        $result = mysql_query($sql) or die(mysql_error());
        $arr_ctdt = array();
        while($row = mysql_fetch_array($result)){
            $arr_ctdt[] = $this->setTblCTDTBLL($row);
        }
        return $arr_ctdt;
    }
    public function setTblCTDTBLL($row){
        $MonCTDT = new TblCTDT();
        $MonCTDT->setTblCTDTDAL($row['Ma_TrinhDo'],$row['Ma_HeDT'],$row['Ma_Nganh']);
        return $TblCTDT;
    }
    public function setAllCTDT($row){
        $allCTDT=new TblCTDT();
        $allCTDT->setAllCTDT($row['Ma_TrinhDo'],$row['Ma_HeDT'],$row['Ma_Nganh']);
        return $allCTDT;
    }
    public function getAll(){
        $sql="SELECT MC.Ma_CTDT, L.Ma_Nganh,M.Ma_TrinhDo, N.Ma_HeDT
              FROM dm_CTDT as MC 
              INNER JOIN tbl_CTDT.Ma_Nganh as L ON MC.Ma_Nganh=L.Ma_Nganh
              INNER JOIN dm_TrinhDo as M ON MC.Ma_TrinhDo=M.Ma_TrinhDo
              INNER JOIN dm_HeDaoTao as N ON MC.Ma_HeDT=N.Ma_HeDT";
        $result = mysql_query($sql) or die(mysql_error());
        $arr_ctdt = array();
        while($row = mysql_fetch_array($result)){
            $arr_ctdt[] = $this->setAllCTDT($row);
        }
        return $arr_ctdt;
    }
}
?>